from bs4 import BeautifulSoup
import requests
import time

with open('jbwtest5.txt', 'r') as r:
    """
    """
    i = 0
    with open('jbwwant5.txt', 'a') as w:
        url = r.readline()
        while url:
            # print(url)
            ret = requests.get('http://www.chinatimber.org/info/' + url.strip()).content.decode('gbk','ignore')
            # print(ret)
            #
            soup = BeautifulSoup(ret)
            text = soup.find('div', class_='Contentbox')
            td = text.find('td')
            name = soup.find('span', class_='titlestyle')

            print(name.get_text())
            print(td.get_text())
            res = name.get_text() +'&&&'+ td.get_text()

            w.write(res)
            w.write("\n")
            url = r.readline()
            i += 1
            print(i)
            time.sleep(1)


    # for i, span in enumerate(spans):
    #     print(span.get_text().strip())
    #     print(i)
    #     if i in [2, 7, 10, 12, 14, 16]:
    #         l.append(span.get_text().strip())
    # s = "$$$".join(l)
    # print(s)
    # return s
